// This example shows how to read a single item and obtains a type code of the received value. // // Find all latest examples here: https://opclabs.doc-that.com/files/onlinedocs/OPCLabs-OpcStudio/Latest/examples.html . // OPC client and subscriber examples in C# on GitHub: https://github.com/OPCLabs/Examples-QuickOPC-CSharp . // Missing some example? Ask us for it on our Online Forums, https://www.opclabs.com/forum/index ! You do not have to own // a commercial license in order to use Online Forums, and we reply to every post. using System; using OpcLabs.EasyOpc.DataAccess; using OpcLabs.EasyOpc.OperationModel; namespace DocExamples.DataAccess._EasyDAClient { partial class ReadItem { public static void GetTypeCode() { // Instantiate the client object. var client = new EasyDAClient(); DAVtq vtq; try { vtq = client.ReadItem("", "OPCLabs.KitServer.2", "Simulation.Random"); } catch (OpcException opcException) { Console.WriteLine("*** Failure: {0}", opcException.GetBaseException().Message); return; } if (!(vtq.Value is null)) { TypeCode typeCode = Type.GetTypeCode(vtq.Value.GetType()); Console.WriteLine("TypeCode: {0}", typeCode); } } } }
' This example shows how to read a single item and obtains a type code of the received value. ' ' Find all latest examples here: https://opclabs.doc-that.com/files/onlinedocs/OPCLabs-OpcStudio/Latest/examples.html . ' OPC client and subscriber examples in VB.NET on GitHub: https://github.com/OPCLabs/Examples-QuickOPC-VBNET . ' Missing some example? Ask us for it on our Online Forums, https://www.opclabs.com/forum/index ! You do not have to own ' a commercial license in order to use Online Forums, and we reply to every post. Imports OpcLabs.EasyOpc.DataAccess Imports OpcLabs.EasyOpc.OperationModel Namespace DataAccess._EasyDAClient Partial Friend Class ReadItem Public Shared Sub GetTypeCode() Dim client = New EasyDAClient() Dim vtq As DAVtq Try vtq = client.ReadItem("", "OPCLabs.KitServer.2", "Simulation.Random") Catch opcException As OpcException Console.WriteLine("*** Failure: {0}", opcException.GetBaseException().Message) Exit Sub End Try If vtq.Value IsNot Nothing Then Dim typeCode As TypeCode = Type.GetTypeCode(vtq.Value.GetType()) Console.WriteLine("TypeCode: {0}", typeCode) End If End Sub End Class End Namespace
Copyright © 2004-2024 CODE Consulting and Development, s.r.o., Plzen. All rights reserved. Web page: www.opclabs.com
Documentation Home, Send Feedback. Resources: Knowledge Base, Product Downloads. Technical support: Online Forums, FAQ.Missing some example? Ask us for it on our Online Forums! You do not have to own a commercial license in order to use Online Forums, and we reply to every post.